<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品group列表页</title>
    <#assign path="${springMacroRequestContext.getContextPath()}" >
    <link rel="stylesheet" href="${path}/static/bootstrap-3.4.1/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="${path}/static/bootstrap-3.4.1/css/bootstrap-theme.css" type="text/css" />
    <link rel="stylesheet" href="https://at.alicdn.com/t/c/font_2937172_jowcw32m21j.css" />
    <script src="${path}/static/bootstrap-3.4.1/js/jquery.min.js"></script>
    <script src="${path}/static/bootstrap-3.4.1/js/bootstrap.js"></script>
    <script src="${path}/static/bootstrap-3.4.1/js/bootstrap-confirmation.min.js"></script>
</head>
<body class="container">
<p>
<div class="row">
    <div class="col-md-8">
        <#if ACCOUNT?? && ACCOUNT.userType?? && ACCOUNT.userType==1>
        <button type="button" class="btn btn-primary" onclick="addGroup()">添加产品组</button>
        </#if>
    </div>
    <#include "common/welcome.html" />
</div>
</p>
<div>
    <ul class="nav nav-tabs">
        <!--    <li role="presentation" class="active"><a href="#">产品原型</a></li>-->
        <!--    <li role="presentation"><a href="${path}/to_ui">视觉交互稿</a></li>-->
        <!--    <li role="presentation"><a href="${path}/to_other">其他导航</a></li>-->
        <#list prodTypeList as pType>
        <li role="presentation"><a href="${path}/list/${pType.id}">${pType.typeName}</a></li>
        </#list>
<li role="presentation" class="active"><a href="${path}/prod_group">产品组</a></li>
</ul>
<table class="table table-bordered table-striped table-hover">
    <thead>
    <th>产品分组</th>
    <th>最后更新时间</th>
    <th style="text-align: center;">操作</th>
    </thead>
    <tbody>
    <#list prodGroupList as group>
    <tr id="tr_${group.id}">
        <td>${(group.groupName)!''}</td>
        <td><#if group.updateTime??>${group.updateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
        <td  style="text-align: center;width: 20%;">&nbsp;&nbsp;
            <#if ACCOUNT?? && ACCOUNT.userType?? && ACCOUNT.userType==1>
            <button class="btn btn-default btn-xs" onclick="editGroup('${group.id}','${group.groupName}')">修改</button>&nbsp;&nbsp;<button class="btn btn-default btn-xs confirm-btn-cust"  data-toggle="confirmation" data-placement="bottom" attr-id="${group.id}">删除</button>
            </#if>
        </td>
    </tr>
    </#list>
    </tbody>
</table>
</div>
<#include "common/jscommon.html" />
<#include "common/prodGroup.html" />
<script type="text/javascript">
    $(function (){
        $('.confirm-btn-cust').confirmation({
            animation: true,
            placement: "top",
            title: "确定要删除吗？",
            btnOkLabel: '确定',
            btnCancelLabel: '取消',
            onConfirm: function () {
                doDeleteGroup($(this).attr("attr-id"));
            },
            onCancel: function () {
            }
        })
    });

    function doDeleteGroup(groupId){
        $.ajax({
            url: bathPath_+'/prod_group/do_delete/'+groupId,
            type: 'get',
            timeout: 30000,
            beforeSend: function () {
            },
            success: function (result) {
                if (0 == result.error) {
                    $("#tr_"+groupId).remove();
                }else{
                    alert(result.msg);
                }
            }
        });
    }
</script>
</body>
</html>